import React from 'react';
import PropTypes from 'prop-types';
SwitchCell.propTypes = {
    label: PropTypes.any,
    checked: PropTypes.bool,
    onClick: PropTypes.func.isRequired,
    onChange: PropTypes.func.isRequired
};
export default function SwitchCell(props) {
    function onclickCell() {
        _.get(props, ['onClick']) && props.onClick();
    }
    function onClickSwitch(e) {
        e.stopPropagation();
        e.preventDefault();
        _.get(props, ['onChange']) && props.onChange(e);
    }
    return (
        <div className="weui-cell weui-cell_active weui-cell_switch">
            <div className="weui-cell__bd" onClick={() => onclickCell()}>{props.label}</div>
            <div className="weui-cell__ft" onClick={(e) => onClickSwitch(e)}>
                <label htmlFor="switchCP" className="weui-switch-cp">
                    <input id="switchCP" className="weui-switch-cp__input" disabled={true} type="checkbox" checked={props.checked} />
                    <div className="weui-switch-cp__box"></div>
                </label>
            </div>
        </div>
    )
}
